<template>
  <view class="loading-view">
    <view class="mask-hidden-show" v-if="status" @click="onCheckHiddenApi">
      <view class="mask-hidden-show-wrapper">
        <div class="uni-page-refresh--refreshing">
          <div class="uni-page-refresh">
            <!--
            <div class="uni-page-refresh-inner">
              <svg width="24" height="24" viewBox="25 25 50 50" class="uni-page-refresh__spinner">
                <circle stroke="#2BD009" cx="50" cy="50" r="20" fill="none" stroke-width="4" stroke-miterlimit="10" class="uni-page-refresh__path"></circle>
              </svg>
              <span></span>
            </div>
            -->
            <div class="loader-circle-refresh loader-circle-refreshing">
              <div class="loader-circle-inner"></div>
            </div>
          </div>
        </div>
        <div class="loading-text">{{ loadingText }}</div>
        <div class="loading-content">
          <slot></slot>
        </div>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    status: false,
    loadingText: {
      type: String,
      default () {
        return '加载中...'
      }
    }
  },

  data() {
    return {

    }
  },
  
  methods: {
    onCheckHiddenApi () {
			this.$emit('onClickMask')
		}
  }
}
</script>

<style lang="scss">
.loading-view {
  .mask-hidden-show {
    z-index: 101;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, .5);
    display: flex;
    align-items: center;
    justify-content: center;
    .mask-hidden-show-wrapper {
      width: 80%;
      height: 300rpx;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      background-color: rgba(255, 255, 255, .9);
      border-radius: 5px;
    }
  }
}
.loading-content {
  width: 50vw;
}
.loading-text {
  color: #333;
}
.uni-page-refresh,
.uni-page-refresh-inner {
  display: flex;
  width: 40px;
  height: 40px;
  justify-content: center;
  align-items: center;
  border-radius: 50%;
  text-align: center;
}
.uni-page-refresh--refreshing .uni-page-refresh__spinner {
  transform-origin: center center;
  animation: uni-page-refresh-rotate 2s linear infinite;
}
@keyframes uni-page-refresh-rotate {
  100% {
    -webkit-transform: rotate(1turn);
    transform: rotate(1turn);
  }
}
.uni-page-refresh--refreshing .uni-page-refresh__path {
  stroke-dasharray: 1,200;
  stroke-dashoffset: 0;
  stroke-linecap: round;
  animation: uni-page-refresh-dash 1.5s ease-in-out infinite, uni-page-refresh-colorful 6s ease-in-out infinite;
}
@keyframes uni-page-refresh-dash {
  0% {
    stroke-dasharray: 1,200;
    stroke-dashoffset: 0;
  }
  50% {
    stroke-dasharray: 89,200;
    stroke-dashoffset: -35px;
  }
  100% {
    stroke-dasharray: 89,200;
    stroke-dashoffset: -124px;
  }
}

.loader-circle-inner {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border-top: 2px solid rgba(43, 208, 9, 1);
  border-left: 2px solid rgba(43, 208, 9, 0.3);
  border-right: 2px solid rgba(43, 208, 9, 0.3);
  border-bottom: 2px solid rgba(43, 208, 9, 0.3);
  animation: loader-circle 2s infinite linear;
}
@keyframes loader-circle {
	0% {
    transform: rotate(0deg);
	}
	100% {
    transform: rotate(360deg);
	}
}
</style>